#include<stdio.h>
int main(){
    long long a,da,b,db,pa=0,pb=0;
    scanf("%lld%lld%lld%lld",&a,&da,&b,&db);
    while(a!=0){
        int temp = a%10;
        a/=10;
        if(temp==da)
            pa = pa*10+da;
    }
    while(b!=0){
        int temp = b%10;
        b/=10;
        if(temp==db)
            pb = pb*10+db;
    }
    printf("%lld\n",pa+pb);

    return 0;
}